<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IFWiki.Models.Game>" %>
<%@ Import Namespace="IFWiki.Utils"  %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
	<title><%= Html.Encode(Model.Name) %></title>
	<Style type="text/css">
            <%= Html.Encode(Model.GameStyle) %>
    </Style>
   <script type="text/javascript" src="../../Scripts/IfWiki.Cookies.js"></script>    
   <script type="text/javascript" src="../../Scripts/IfWiki.Player.js"></script>    
   <script type="text/javascript" src="../../Scripts/IfWiki.Write.js"></script>    
   <script type="text/javascript" src="../../Scripts/IfWiki.Place.js"></script>    
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="menu" runat="server">
        <div id="menucontainer">
            <ul id="menu">              
                <li><a class="current">Main</a></li>            
                <li><%= Html.ActionLink("Source", "ViewSource", "Game", new { name=Model.Name  }, null)%></li>
                <li><%= Html.ActionLink("Talk", "Talk", "Article", new { name = Model.Name, innerType = Model.InnerType }, null)%></li>
            </ul>
        </div>
    </div>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<script type="text/javascript">

var player;

function starthere() {
  player = new Object;
  eval("<%= Model.StartingPlayerJson.ToSingleLine() %>");
  player.gameToken = guid();
  
  if (player == undefined || player == null) {
    alert("Error loading player! Game over");
    return;
  }
  
  var defaultname = player.name;
  if (defaultname==undefined) { defaultname = 'anonymous coward';}
  //ae_prompt(getplayername, "Hello traveller. What is your name?", defaultname);
  //return;
  player['name'] = defaultname;
  
  goto('<%= Model.StartingGamePlaceName %>','<%= Model.Name %>');
}

function goto(place, game) {
  savePlayer(player);
  //to do: savePlace(currentplaceName, player.token, _place);
  var newlocation = '<%= Request.ApplicationPath %>'
  newlocation += 'Go/' + place + '/' + game;
  document.location.href = newlocation;
}

</script>

<div class='playerinfo'><span id='playerinfo'></span></div>
    <h2><%= Html.Encode(Model.Name) %></h2>

    <%= Html.Encode(Model.AboutGame).ToHtml() %>

        <p>
            <p><span class='linkish' onclick='javascript:starthere();'>Start now!</span></p>
        </p>
</asp:Content>

